- /* sdcbse.cpp by K.Tsuru */
- // function ID = 3554 DRADIX
-
- /***********************************************************************************************
- Basic file for computation of e=2.7181... with Xavier Gourdon's
- binary splitting method.
- CPU time = 23.5017(sec) 10000029(10 million digits) gcc 4.8.1 + CPU Core i7-3770 3.4GHz
- [reference]
- e.c in
- http://xavier.gourdon.free.fr/Constants/constants.html
- The implement is almost the same.
-
- Xavier Gourdon's binary splitting method is based on the original work of
- E.A.Karatsuba, "Fast evaluation of hypergeometric functions by FEE", CMFT'97.
- See "Binary splitting method" in http://numbers.computation.free.fr/Constants/constants.html .
- ************************************************************************************************/
-
- #ifndef SN_H
- #include "sn.h"
- #endif
- /********************
- In snum.h
-
- #define SLONG 2
- #define SDOUBLE 3
- #define SDEC_INT 4
-
- are defined.
-
- Speed test for 524,252 digits on Pentium 4 3GHz.
-
- version | CPU time (sec.)
- ---------------------
- SLONG | 6.2 ... fastest
- SDOUBLE | 9.3
- SDEC_INT| 9.65
- ********************/
- ////////////////////
- #define BSE_TYPE SLONG // for speed test change here
- ///////////////////
-
- #if BSE_TYPE==SLONG
-
- /// SLong version ///
-
- class BSExp1 : public BinarySplittingA1C<SLong> {
- public:
- BSExp1(long L, long prec) : BinarySplittingA1C<SLong>(L, prec) {}
-
- void setAC(long k, SLong& a, SLong& c) {
- a.SetSmall(1); c.SetLong(k + 1L);
- }
-
- SDouble getValue() {
- putTogether();
- return BinarySplittingA1C<SLong>::getValue() + 1.0;
- }
- };
- #elif BSE_TYPE==SDEC_INT
-
- /// SInteger version ///
-
- class BSExp1 : public BinarySplittingA1C<SInteger> {
- public:
- BSExp1(long L, long prec) : BinarySplittingA1C<SInteger>(L, prec) {}
-
- void setAC(long k, SInteger& a, SInteger& c) {
- a.SetSmall(1); c.SetLong(k + 1L);
- }
-
- SDouble getValue() {
- putTogether();
- SLong a , c;
- a = getA().ConvToDec();
- c = getC().ConvToDec();
- return SDouble(a) / SDouble(c) + 1.0;
- }
- };
- #else
- /// SDouble version ///
- class BSExp1 : public BinarySplittingA1C<SDouble> {
- public:
- BSExp1(long L, long prec) : BinarySplittingA1C<SDouble>(L, prec) {}
-
- void setAC(long k, SDouble& a, SDouble& c) {
- a.SetSmall(1);
- //c = k + 1L;
- c.SetInt(k + 1L);
- }
-
- SDouble getValue() {
- putTogether();
- return BinarySplittingA1C<SDouble>::getValue() + 1.0;
- }
- };
-
- #endif
-
- SDouble BSE() {
- SDouble temp;
- long prec = long(temp.EffFig() + temp.Hidden()) * DFIGURES;
- long L = upToExpSeries(prec, 0.0);
-
- #if BSE_TYPE==SDOUBLE
- BSExp1 e(L, 0); // does not need roundoff
- #else
- BSExp1 e(L, prec);
- #endif
- return e.getValue();
- }
sdcbse.cpp : last modifiled at 2017/03/17 11:10:45(2,708 bytes)
created at 2017/10/07 10:21:15
The creation time of this html file is 2017/10/07 10:30:03 (Sat Oct 07 10:30:03 2017).